/*******************************************************************************************/
// jquery.event.wheel.js - rev 1
// Copyright (c) 2008, Three Dub Media (http://threedubmedia.com)
// Liscensed under the MIT License (MIT-LICENSE.txt)
// http://www.opensource.org/licenses/mit-license.php
// Created: 2008-07-01 | Updated: 2008-07-14
// $(body).bind('wheel',function(event,delta){    alert(delta>0 ? "up" : "down");    });
/*******************************************************************************************/

;(function($){

  $.event.special.wheel = {
    _b: $.browser.mozilla ? "DOMMouseScroll" : "mousewheel",
    _h: function(a)
    {
      switch (a.type)
      {
        case "mousemove"     :
          return $.extend(a.data, {clientX: a.clientX, clientY: a.clientY, pageX: a.pageX, pageY: a.pageY});
        case "DOMMouseScroll":
          $.extend(a, a.data);
          a.delta = -a.detail / 3;
          break;
        case "mousewheel"    :
          a.delta = a.wheelDelta / 120;
          if ($.browser.opera)
            a.delta = -a.delta;
          break;
      }
      a.type = "wheel";
      return $.event.handle.call(this, a, a.delta);
    }
  }
  if ($.browser.mozilla && ($.browser.version < "1.9"))
    $.event.special.wheel._b += " mousemove";

  $.extend($.event.special.wheel, {
    setup   : function(){$.event.add(this,$.event.special.wheel._b,$.event.special.wheel._h,{});},
    teardown: function(){$.event.remove(this,$.event.special.wheel._b,$.event.special.wheel._h);}
  });

  $.fn.wheel = function(f){return this[f?"bind":"trigger"]("wheel",f)};

})(jQuery);
